import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { ModDataButton, DelDataButton, OpenExcelButton } from '../Common/options'
import { v4 } from 'uuid'

export const CostManagements = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getCostManagementExcel',
                    pos: 'posCostManagementExcel',
                    CostManagementUuid: v4(),
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'CostManagements' },

            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, hideInModify: true },
            {
                dataIndex: 'beginEventDate',
                title: '开始日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'endEventDate',
                title: '结束日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
            },
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 160,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenExcelButton
                            key="two"
                            title="查看明细"
                            OptionsEvent={OptionsEvent}
                            data={{
                                save: true,
                                submit: true,
                                url: 'getCostManagementExcel',
                                pos: 'posCostManagementExcel',
                                CostManagementUuid: record.uuid,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
